/**
 * 老师类
 * 
 * 老师与学生一对多
 * 老师和研究方向多对多
 * 
 */
package com.zgt.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.springframework.context.annotation.Lazy;

@Entity
@Table(name = "t_teacher")
public class Teacher {
	private int id;
	private String workNum; // 工号===登陆帐号
	private String password;
	private String name; // 姓名
	private String sex; // 性别
	private String title; // 职称
	private String edu; // 学历
	private String degree; // 学位
	private int studentCount; // 指导人数
	private String telephone;
	private String email;

	private List<Research> researchs = new ArrayList<Research>(); // 研究方向

	private List<Student> students = new ArrayList<Student>();// 指导的学生

	@OneToMany(mappedBy = "teacher", fetch = FetchType.EAGER)
	public List<Student> getStudents() {
		return students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getWorkNum() {
		return workNum;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setWorkNum(String workNum) {
		this.workNum = workNum;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getEdu() {
		return edu;
	}

	public void setEdu(String edu) {
		this.edu = edu;
	}

	public String getDegree() {
		return degree;
	}

	public void setDegree(String degree) {
		this.degree = degree;
	}

	public int getStudentCount() {
		return studentCount;
	}

	public void setStudentCount(int studentCount) {
		this.studentCount = studentCount;
	}

	@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
	@JoinTable(name = "t_teachre_research")
	public List<Research> getResearchs() {
		return researchs;
	}

	public void setResearchs(List<Research> researchs) {
		this.researchs = researchs;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getEmail() {
		return email;
	}

}
